package com.fare.taluo.util.excel.engine;

import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.fare.taluo.util.excel.engine.operate.IExcelWrite;
import com.fare.taluo.util.excel.engine.operate.impl.ExcelWriteImpl;

public class ExcelParseFactory {
	/**
	 * log4j的日志记录
	 */
	protected static Logger logger = Logger.getLogger(ExcelParseFactory.class);
	private static IExcelWrite excelWrite = null;

	/**
	 * 得到excel写服务
	 * 
	 * @return
	 */
	private static IExcelWrite getExcelWriteInstance() {
		if (excelWrite == null) {
			excelWrite = new ExcelWriteImpl();
		}
		return excelWrite;
	}

	/**
	 * 向excel表中写数入数据
	 * 
	 * @param moduleName:
	 *            配置文件中的excel元素的id
	 * @param dataMap ：
	 *            要写入的数据
	 * @param contextMap ：
	 *            上下文map，用来替换配置文件中的表达式
	 * @param outputStream
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public static void writeExcelNoCalculate(String moduleName,
			Map<String, List> dataMap, Map<String, String> contextMap,
			OutputStream outputStream) {
		try {
			getExcelWriteInstance().writeExcelNoCalculate(moduleName, dataMap,
					contextMap, outputStream);
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
		}
	}

}
